home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Developer's Kit 1996
/
Delphi Developer's Kit 1996.iso
/
power
/
ctrlkits
/
graphbtn.int
< prev
next >
Wrap
Text File
|
1995-12-22
|
2KB
|
61 lines
unit GraphBtn;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, ExtCtrls;
const
IDX_BTNFACE = 0;
IDX_BTNSHADOW = 1;
IDX_BTNHILIGHT = 2;
type
TBtnDrawEvent = procedure (Sender: TObject;
IsDown, IsDefault, IsFocused, IsNewStyle : Boolean;
Canvas : TCanvas;
Rect : TRect) of object;
TBtnColors = Array[IDX_BTNFACE..IDX_BTNHILIGHT] of TColor;
TGraphicButton = class(TButton)
private
FCanvas : TCanvas;
FStyle : TButtonStyle;
FColors : TBtnColors;
IsFocused : Boolean;
FOnDrawFace : TBtnDrawEvent;
procedure CNMeasureItem(var Message: TWMMeasureItem); message CN_MEASUREITEM;
procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure SetStyle(AStyle : TButtonStyle);
procedure SetColor(Index : Integer; AColor : TColor);
function GetColor(Index : Integer): TColor;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure SetButtonStyle(ADefault: Boolean); override;
procedure DrawItem(const DrawItemStruct: TDrawItemStruct); virtual;
procedure DrawBtnFace(IsDown, IsDefault, IsFocused, IsNewStyle : Boolean;
const ARect : TRect); virtual;
property Canvas : TCanvas read FCanvas; {do not publish}
property ColorFace : TColor index IDX_BTNFACE read GetColor write SetColor default clBtnFace;
property ColorShadow : TColor index IDX_BTNSHADOW read GetColor write SetColor default clBtnShadow;
property ColorHiLight : TColor index IDX_BTNHILIGHT read GetColor write SetColor default clBtnHighlight;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Style : TButtonStyle read FStyle write SetStyle default bsAutoDetect;
property OnDrawFace: TBtnDrawEvent read FOnDrawFace write FOnDrawFace;
end;
implementation
end.